package org.leiyang.common.util;

import java.time.format.DateTimeFormatter;

/**
 * 常量
 */
public class Constants {

    /**
     * 成功标记
     */
    public static final Integer SUCCESS = 200;

    /**
     * 失败标记
     */
    public static final Integer FAIL = 500;

    /**
     * netty的分隔符
     */
    public static String DELIMITER = "$(* *)$";

    //单次包最大4M
    public static int MAX_LENGTH = 4 * 1024 * 1024;

    /**
     * 注册在线MsgServer的信息
     * 格式: OnlineServerKey + address:port
     */
    public final static String online_server_key = "/online/s/";

    /**
     * 加解密口令
     */
    public final static String encryptPwd = "ding87OP";

    /**
     * 存储登录用户信息的KEY
     */
    public final static String ACCESS_TOKEN = "l_token:";

    /**
     * token有效期, 单位是秒
     */
    public final static int EXPIRATION = 43200;

    /**
     * 令牌自定义标识
     */
    public static final String AUTHENTICATION = "Authorization";

    /**
     * 令牌前缀
     */
    public static final String PREFIX = "Bearer ";

    /**
     * 用户标识
     */
    public static final String USER_KEY = "user_key";

    /**
     * 用户ID字段
     */
    public static final String DETAILS_USER_ID = "user_id";

    /**
     * 用户名字段
     */
    public static final String DETAILS_USERNAME = "username";

    /**
     * 客户端的出口公网IP
     */
    public static final String CLIENT_IP = "client_ip";

    /**
     * 用于缓存离线消息的KEY
     * 格式: OFFLINE_MSGS_KEY + uid
     */
    public static final String OFFLINE_MSGS_KEY = "off:msgs:";

    /**
     * 用于生成{@link org.leiyang.common.entities.MsgOneToOne#id}
     */
    public static final String MSG_ID_KEY = "msg:id";

    /**
     * 接收 客户端返回的推送消息成功的响应消息
     */
    public static final String MSG_REC_SUCCESS_TOPIC = "msg_rec_success_topic";

    /**
     * 接收 客户端返回的推送消息成功的响应消息 的消费组
     */
    public static final String MSG_REC_SUCCESS_GROUP_ID = "msg_rec_success_group";

    /**
     * 记录已经更新的{@link org.leiyang.common.entities.MsgOneToOne}的ID
     */
    public static final String FILTER_RECE_MSG_IDS = "filter:rece:msgs:ids";
    /**
     * 时间格式化器
     */
    public static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    /**
     * 用于存储nettyServer地址对应的WEB通信地址，供其他服务进行RPC调用
     * 格式: MSG_SER_WEB_INFO + [ip:port]
     */
    public static final String MSG_SER_WEB_INFO = "web:info:";

    /**
     * 用于存储nettyServer地址对应的RSocket服务端的通信地址，供其他服务进行RPC调用
     * 格式: MSG_SER_RSOCKET_INFO + [ip:port]
     */
    public static final String MSG_SER_RSOCKET_INFO = "rs:info:";
}